package com.util;

import java.util.List;

import com.entity.Filer;
import com.entity.Task;
import com.service.FilerService;
import com.service.GoalService;

public class GoalStateHelp {

	public static Float getSum(String folderid){
		FilerService fs=new FilerService();
		List<Filer> fList=fs.findAllFiler(folderid);
		float total=0f;
		
		for(Filer f:fList){
			Float str=f.getSize();
			total+=str;
			
		}
		
		Float fss=total/(1024*1024);
		return fss;
	}
	
	public static long getCount(String folderid){
		return new FilerService().count(folderid);
	}
	
	public static float getState(String goalid){
		List<Task> tasklist=new GoalService().findTaskAll(goalid);
		float total=0f;
		int i=0;
		for(Task task:tasklist){
			Float str=task.getPlan();
			total+=str;
			i++;
		}
		return total/i;
	}
}
